package com.wqtz.chechai.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2016/12/19 10:00
 */

public class FirstPagerAdapter extends PagerAdapter {
	List<ImageView> mImageViews;

	public FirstPagerAdapter(List<ImageView> imageViews) {
		mImageViews = imageViews;
	}

	@Override
	public int getCount() {
		return mImageViews==null?0:mImageViews.size();
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view == object;
	}

	//加载页面
	//ViewGroup:父控件指ViewPager
	//position:当前子控件在父控件中的位置
	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		ImageView iv = mImageViews.get(position);
		container.addView(iv);
		return iv;
	}

	//移除页面
	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView((View) object);
	}
}
